package com.zhiwang.planet.widget

import android.content.Context
import android.util.AttributeSet
import android.view.ViewGroup.LayoutParams.WRAP_CONTENT
import android.widget.ImageView
import android.widget.LinearLayout
import com.bumptech.glide.Glide
import com.zhiwang.planet.util.dp

class VipImageListView(context: Context?, attrs: AttributeSet?) : LinearLayout(context, attrs) {


    init {
        orientation = HORIZONTAL
    }

    fun setImageList(urls: List<String>) {

        removeAllViews()
        addImage(urls)
    }

    private fun addImage(urls: List<String>) {


        val lp = LinearLayout.LayoutParams(20.dp, 20.dp)
        urls.forEach {
            val iv = ImageView(context)
            Glide.with(iv)
                    .load(it)
                    .into(iv)

            addView(iv, lp)
        }
    }
}